﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace D3crft.Characters {
    public static class scCharacterAnalysis {

        public static float GetCharacterDPS(ClassObjects.ocCharacter oCharacter) {
            float fDPS = 0.0f;
            float fMHDMG, fOHDMG, fOHAPS;

            if (oCharacter.eClass == ClassObjects.ocCharacter.eCharacterClass.Barbarian) {
                if (((ClassObjects.ocBarbarian)oCharacter).bWeaponStat_Dualwield) {
                    // DW
                    fMHDMG = oCharacter.fWeaponStats_MHDPS / oCharacter.fWeaponStats_MHAPS;
                    fOHDMG = ((ClassObjects.ocBarbarian)oCharacter).fWeaponStats_OHDPS / ((ClassObjects.ocBarbarian)oCharacter).fWeaponStats_OHAPS;
                    fOHAPS = ((ClassObjects.ocBarbarian)oCharacter).fWeaponStats_OHAPS;
                    fDPS = ((fMHDMG + fOHDMG + ((float)oCharacter.iOffStat_BonusDamage_Min + (float)oCharacter.iOffStat_BonusDamage_Max)) * (oCharacter.fWeaponStats_MHAPS * fOHAPS) / (oCharacter.fWeaponStats_MHAPS + fOHAPS)) * (1.0f + (oCharacter.fOffStat_AttackSpeedInrease / 100.0f)) * (1.0f + ((oCharacter.fOffStat_CritChance / 100.0f) * (oCharacter.fOffStat_CritDamage / 100.0f))) * (1.0f + ((float)oCharacter.iBaseStat_Strength / 100.0f));
                }
                else {
                    // 1Handed
                    fMHDMG = oCharacter.fWeaponStats_MHDPS / oCharacter.fWeaponStats_MHAPS;
                    fDPS = ((fMHDMG + (((float)oCharacter.iOffStat_BonusDamage_Min + (float)oCharacter.iOffStat_BonusDamage_Max) / 2.0f)) * (oCharacter.fWeaponStats_MHAPS)) * (1.0f + (oCharacter.fOffStat_AttackSpeedInrease / 100.0f)) * (1.0f + ((oCharacter.fOffStat_CritChance / 100.0f) * (oCharacter.fOffStat_CritDamage / 100.0f))) * (1.0f + ((float)oCharacter.iBaseStat_Strength / 100.0f));
                }
            }
            else if (oCharacter.eClass == ClassObjects.ocCharacter.eCharacterClass.Crusader) {
                // 1Handed
                fMHDMG = oCharacter.fWeaponStats_MHDPS / oCharacter.fWeaponStats_MHAPS;
                fDPS = ((fMHDMG + (((float)oCharacter.iOffStat_BonusDamage_Min + (float)oCharacter.iOffStat_BonusDamage_Max) / 2.0f)) * (oCharacter.fWeaponStats_MHAPS)) * (1.0f + (oCharacter.fOffStat_AttackSpeedInrease / 100.0f)) * (1.0f + ((oCharacter.fOffStat_CritChance / 100.0f) * (oCharacter.fOffStat_CritDamage / 100.0f))) * (1.0f + ((float)oCharacter.iBaseStat_Strength / 100.0f));
            }
            else if (oCharacter.eClass == ClassObjects.ocCharacter.eCharacterClass.Demon_Hunter) {
                if (((ClassObjects.ocDemonHunter)oCharacter).bWeaponStat_Dualwield) {
                    // DW
                    fMHDMG = oCharacter.fWeaponStats_MHDPS / oCharacter.fWeaponStats_MHAPS;
                    fOHDMG = ((ClassObjects.ocDemonHunter)oCharacter).fWeaponStats_OHDPS / ((ClassObjects.ocDemonHunter)oCharacter).fWeaponStats_OHAPS;
                    fOHAPS = ((ClassObjects.ocDemonHunter)oCharacter).fWeaponStats_OHAPS;
                    fDPS = ((fMHDMG + fOHDMG + ((float)oCharacter.iOffStat_BonusDamage_Min + (float)oCharacter.iOffStat_BonusDamage_Max)) * (oCharacter.fWeaponStats_MHAPS * fOHAPS) / (oCharacter.fWeaponStats_MHAPS + fOHAPS)) * (1.0f + (oCharacter.fOffStat_AttackSpeedInrease / 100.0f)) * (1.0f + ((oCharacter.fOffStat_CritChance / 100.0f) * (oCharacter.fOffStat_CritDamage / 100.0f))) * (1.0f + ((float)oCharacter.iBaseStat_Dexterity / 100.0f));
                }
                else {
                    // 1Handed
                    fMHDMG = oCharacter.fWeaponStats_MHDPS / oCharacter.fWeaponStats_MHAPS;
                    fDPS = ((fMHDMG + (((float)oCharacter.iOffStat_BonusDamage_Min + (float)oCharacter.iOffStat_BonusDamage_Max) / 2.0f)) * (oCharacter.fWeaponStats_MHAPS)) * (1.0f + (oCharacter.fOffStat_AttackSpeedInrease / 100.0f)) * (1.0f + ((oCharacter.fOffStat_CritChance / 100.0f) * (oCharacter.fOffStat_CritDamage / 100.0f))) * (1.0f + ((float)oCharacter.iBaseStat_Dexterity / 100.0f));
                }
            }
            else if (oCharacter.eClass == ClassObjects.ocCharacter.eCharacterClass.Monk) {
                if (((ClassObjects.ocMonk)oCharacter).bWeaponStat_Dualwield) {
                    // DW
                    fMHDMG = oCharacter.fWeaponStats_MHDPS / oCharacter.fWeaponStats_MHAPS;
                    fOHDMG = (((ClassObjects.ocMonk)oCharacter).fWeaponStats_OHDPS) / (((ClassObjects.ocMonk)oCharacter).fWeaponStats_OHAPS);
                    fOHAPS = ((ClassObjects.ocMonk)oCharacter).fWeaponStats_OHAPS;
                    fDPS = ((fMHDMG + fOHDMG + ((float)oCharacter.iOffStat_BonusDamage_Min + (float)oCharacter.iOffStat_BonusDamage_Max)) * (oCharacter.fWeaponStats_MHAPS * fOHAPS) / (oCharacter.fWeaponStats_MHAPS + fOHAPS)) * (1.0f + (oCharacter.fOffStat_AttackSpeedInrease / 100.0f)) * (1.0f + ((oCharacter.fOffStat_CritChance / 100.0f) * (oCharacter.fOffStat_CritDamage / 100.0f))) * (1.0f + ((float)oCharacter.iBaseStat_Dexterity / 100.0f));
                }
                else {
                    // 1Handed
                    fMHDMG = oCharacter.fWeaponStats_MHDPS / oCharacter.fWeaponStats_MHAPS;
                    fDPS = ((fMHDMG + (((float)oCharacter.iOffStat_BonusDamage_Min + (float)oCharacter.iOffStat_BonusDamage_Max) / 2.0f)) * (oCharacter.fWeaponStats_MHAPS)) * (1.0f + (oCharacter.fOffStat_AttackSpeedInrease / 100.0f)) * (1.0f + ((oCharacter.fOffStat_CritChance / 100.0f) * (oCharacter.fOffStat_CritDamage / 100.0f))) * (1.0f + ((float)oCharacter.iBaseStat_Dexterity / 100.0f));
                }
            }
            else if (oCharacter.eClass == ClassObjects.ocCharacter.eCharacterClass.Witch_Doctor) {
                // 1Handed
                fMHDMG = oCharacter.fWeaponStats_MHDPS / oCharacter.fWeaponStats_MHAPS;
                fDPS = ((fMHDMG + (((float)oCharacter.iOffStat_BonusDamage_Min + (float)oCharacter.iOffStat_BonusDamage_Max) / 2.0f)) * (oCharacter.fWeaponStats_MHAPS)) * (1.0f + (oCharacter.fOffStat_AttackSpeedInrease / 100.0f)) * (1.0f + ((oCharacter.fOffStat_CritChance / 100.0f) * (oCharacter.fOffStat_CritDamage / 100.0f))) * (1.0f + ((float)oCharacter.iBaseStat_Intelligence / 100.0f));
            }
            else if (oCharacter.eClass == ClassObjects.ocCharacter.eCharacterClass.Wizard) {
                // 1Handed
                fMHDMG = oCharacter.fWeaponStats_MHDPS / oCharacter.fWeaponStats_MHAPS;
                fDPS = ((fMHDMG + (((float)oCharacter.iOffStat_BonusDamage_Min + (float)oCharacter.iOffStat_BonusDamage_Max) / 2.0f)) * (oCharacter.fWeaponStats_MHAPS)) * (1.0f + (oCharacter.fOffStat_AttackSpeedInrease / 100.0f)) * (1.0f + ((oCharacter.fOffStat_CritChance / 100.0f) * (oCharacter.fOffStat_CritDamage / 100.0f))) * (1.0f + ((float)oCharacter.iBaseStat_Intelligence / 100.0f));
            }

            return fDPS;
        }
    }
}
